﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UploadWizardControl.ascx.cs"
    Inherits="controls_UploadWizardControl" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Src="~/_controltemplates/toolbar.ascx" TagName="ToolBar" TagPrefix="SharePoint" %>
<style>
    
    .distributionOptionsLink
    {
    }
    .distrubitionOptionsLink:hover
    {
        color: #3966bf !important;
        text-decoration: none !important;
    }
    
</style>

<script src="/_layouts/FileExchangeLayouts/resources/StringResources.aspx" type="text/javascript">

</script>

<div id="MainContentDiv">
    <table width="100%" style="height: 100%" cellpadding="0" cellspacing="5" class="ms-authoringcontrols ikea-whitebackround">
        <tr>
            <td>
                <span class="ms-descriptiontext" style="font-weight: bold;">Please select files to upload:</span>
            </td>
        </tr>
        <tr>
            <td style="height: 300px;">
                <iframe id="fileListsFrame" width="100%" frameborder="0" height="100%" style="border: 0px;"
                    src="_layouts/FileExchangeLayouts/iframe/FilesToUploadList.aspx"></iframe>
            </td>
        </tr>
        <tr>
            <td>
                <a href="javascript:AddFile();">More files</a>
            </td>
        </tr>
        <tr>
            <td>
                <asp:CheckBox ID="cbConfidentialUpload" onclick="cbConfidentialUpload_Click();" runat="server"
                    Text="Confidential upload" Style="margin: 0 0 0 0" />
            </td>
        </tr>
        <tr>
            <td>
                <table cellpadding="0" style="margin: 0 0 0 0">
                    <tr>
                        <td style="padding-bottom: 2px;">
                            <img id="Img1" runat="server" src="~/_layouts/images/plus.gif" onclick="SwitchAdditionalOptions()"
                                style="cursor: hand;" />
                        </td>
                        <td class="ms-descriptiontext" valign="middle">
                            &nbsp;<a href="javascript:SwitchAdditionalOptions();" class="distrubitionOptionsLink"><b>Distribution
                                and follow up options</b></a>
                        </td>
                    </tr>
                </table>
                <div id="additionOptionsHolder" style="padding-left: 3px; width: 99%; display: none;">
                    <table width="99%">
                        <colgroup>
                            <col width="44%" />
                            <col width="56%" />
                        </colgroup>
                        <tr>
                            <td colspan="2">
                                <SharePoint:ToolBar runat="server">
                                    <template_buttons>
                                <asp:PlaceHolder ID="PlaceHolder3" runat="server">
                                    &nbsp;<span class="ms-linksectionheader"><b>Recipients</b></span>
                                </asp:PlaceHolder>
                            </template_buttons>
                                </SharePoint:ToolBar>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top">
                                <span class="ms-descriptiontext">Type email addresses of the persons who will receive the
                                    link to the files.
                                    <br />
                                     </span>
                                <div class="ms-descriptiontext" style="margin-top: 10px;">
                                    <i><b>Example</b></i>
                                </div>
                                <div class="ms-descriptiontext">
                                    <i>ivan.petrov@memo.ikea.com;elena.alekseeva@memo.ikea.com; patrick.suiyze@gmail.com</i>
                                </div>
                            </td>
                            <td>
                                <asp:TextBox ID="txtRecipients" TextMode="MultiLine" Height="150px" runat="server"
                                    Width="100%" CssClass="ms-long" Style="border: 1px #666666 solid; scrollbar: none;"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <SharePoint:ToolBar runat="server">
                                    <template_buttons>
                            <asp:PlaceHolder ID="PlaceHolder1" runat="server">
                                &nbsp;<span class="ms-linksectionheader"><b>Management</b></span>
                            </asp:PlaceHolder>
                        </template_buttons>
                                </SharePoint:ToolBar>
                            </td>
                        </tr>
                        <tr>
                            <td class="ms-descriptiontext">
                                <asp:CheckBox ID="cbSendManagementLink" CssClass="ms-descriptiontext" runat="server"
                                    Text="Send me a link to the management interface:" Style="margin-left: 0px;" />
                            </td>
                            <td class="ms-descriptiontext">
                                <asp:TextBox ID="txtOwnerEmailAddress" runat="server" Width="400px" CssClass="ms-long"
                                    Text="" onclick="if (this.value=='My email address') this.value='';"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding-left: 5px;">
                                <span class="ms-descriptiontext">These files will be deleted on:</span>
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlCleanupDate" runat="server">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <SharePoint:ToolBar runat="server">
                                    <template_buttons>
                            <asp:PlaceHolder ID="PlaceHolder2" runat="server">
                                &nbsp;<span class="ms-linksectionheader"><b>Upload comments</b></span>
                            </asp:PlaceHolder>
                        </template_buttons>
                                </SharePoint:ToolBar>
                            </td>
                        </tr>
                        <tr>
                             <td style="padding-left: 5px;" valign="top">
                                <span class="ms-descriptiontext">
                                    This text is included in email message which will be send to recipients.
                                </span>
                            </td>
                            <td align="center">
                                <asp:TextBox ID="txtUploadComments" runat="server" TextMode="MultiLine" Width="100%"
                                    Height="200px" CssClass="ms-input" Style="border: 1px #666666 solid"></asp:TextBox>
                                    
                                
                            </td>
                        </tr>
                    </table>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <table>
                    <tr>
                        <td style="padding-right: 20px;">
                            
                            
                            <table cellspacing="0" cellpadding="0" class="vista_toolbar">
                                    <tbody>
                                        <tr>
                                            <td valign="top" class="vista_toolbar_leftborder" />
                                            <td align="center" class="vista_toolbar_content">
                                                <table align="center">
                                                    <tbody>
                                                        <tr>
                                                            <td align="center" />
                                                            <td>
                                                                <asp:LinkButton runat="server" ID="btnStart" Text="Start Upload" OnClientClick="StartUpload();return false;"
                                                                    OnClick="btnStart_Click"></asp:LinkButton>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                        </td>
                        <td>
                            <span>
                                <table cellspacing="0" cellpadding="0" class="vista_toolbar">
                                <tbody>
                                    <tr>
                                        <td valign="top" class="vista_toolbar_leftborder" />
                                        <td align="center" class="vista_toolbar_content">
                                            <table align="center">
                                                <tbody>
                                                    <tr>
                                                        <td align="center" />
                                                        <td>
                                                            <asp:LinkButton runat="server" ID="btnCancel" Text="Cancel" OnClick="btnCancel_Click"></asp:LinkButton>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            </span>
                        </td>  
                    </tr>
                </table>
                &nbsp;
            </td>
        </tr>
    </table>
</div>
<div id="Loading" style="text-align: center; display: none;">
    <img runat="server" src="~/_layouts/fileexchangelayouts/images/progress.gif" />
    <br />
    <span class="ms-descriptiontext"><b>Uploading files in progress...</b></span>
</div>
<asp:HiddenField runat="server" ID="hfTargetFolder" />
<asp:HiddenField runat="server" ID="hfUploadedFileIdents" />

<script type="text/javascript">
  
function AddFile()
{
    window.FileUploadsListManager.addFileToUploadCtrl();    
}
 
function EnsureAdditionalOptions()
{
    
} 

function EnsureSendManagementLink()
{
    var cbSendManagementLink = document.getElementById("<%= cbSendManagementLink.ClientID %>");

    if (cbSendManagementLink.checked == false)
    {
        cbSendManagementLink.checked = true;
    }
}

function SwitchAdditionalOptions()
{
    var additionOptionsHolder = document.getElementById("additionOptionsHolder");
           
    var Img1 = document.getElementById("<%= Img1.ClientID %>");
    
    if (additionOptionsHolder.style.display == "none")
    {
        additionOptionsHolder.style.display = "block";
        Img1.src = "_layouts/images/minus.gif";
        
        
        EnsureSendManagementLink();
    }
    else
    {
        additionOptionsHolder.style.display = "none";
        Img1.src = "_layouts/images/plus.gif";
    }
    
}

function EnsureConfidentiality()
{

    var cbConfidentialUpload = document.getElementById("<%= cbConfidentialUpload.ClientID %>");
    
    window.FileUploadsListManager.setConfidentiality(cbConfidentialUpload.checked);
}

function StartUpload()
{
    var MainContentDiv = document.getElementById("MainContentDiv");
        
    var fileListsFrame = document.getElementById("fileListsFrame");
    fileListsFrame.onreadystatechange = OnFileListsFrameLoaded;
    
    var targetFolder = document.getElementById("<%= hfTargetFolder.ClientID %>").value;
    window.FileUploadsListManager.setTargetFolder(targetFolder);
    
    var fileDeletionDate = document.getElementById("<%= ddlCleanupDate.ClientID %>").value;
        
    window.FileUploadsListManager.setFileDeletionDate(fileDeletionDate);
    
    EnsureConfidentiality();
    
    SwitchLoading();
   
        
    window.setTimeout(PostFileUploadsToServer,500);    
}

function PostFileUploadsToServer()
{    
    window.FileUploadsListManager.postForm();
}

function SwitchLoading()
{
    var MainContentDiv = document.getElementById("MainContentDiv");
    var Loading = document.getElementById("Loading");
    
    if (MainContentDiv.style.display == "none")
    {
        MainContentDiv.style.display = "block";
        Loading.style.display = "none";
    }
    else
    {
        MainContentDiv.style.display = "none";
        Loading.style.display = "block";
    }
}

function OnFileListsFrameLoaded()
{
    var fileListsFrame = document.getElementById("fileListsFrame");
    
    if (fileListsFrame.readyState == "complete")
    {
        if (window.FileUploadsListManager.getLastErrors() == null)
        {
            var uploadedFileIdents = window.FileUploadsListManager.getUploadedFileIdents();
            
            var hfUploadedFileIdents = document.getElementById("<%= hfUploadedFileIdents.ClientID %>");
            hfUploadedFileIdents.value = uploadedFileIdents;

            <%= Page.ClientScript.GetPostBackEventReference(new PostBackOptions(btnStart, string.Empty)) %>
        }
        else
        {
            SwitchLoading();
            alert(window.FileUploadsListManager.getLastErrors());
        }
    }
}

function cbConfidentialUpload_Click()
{    
    SwitchAdditionalOptions();              
}

function SwitchOptionsOnFirstLoad()
{
    var additionOptionsHolder = document.getElementById("additionOptionsHolder");
           
    var Img1 = document.getElementById("<%= Img1.ClientID %>");
    var cbConfidentialUpload = document.getElementById("<%= cbConfidentialUpload.ClientID %>");
    
    if (cbConfidentialUpload.checked)
    {
        additionOptionsHolder.style.display = "block";
        Img1.src = "_layouts/images/minus.gif";
        
        EnsureSendManagementLink();
    }
    else
    {
        additionOptionsHolder.style.display = "none";
        Img1.src = "_layouts/images/plus.gif";
    }
}

 SwitchOptionsOnFirstLoad();
 
</script>

